﻿using ClassLibrary;
using Sunny.UI;
//using Sunny.UI.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Forms
{
    public partial class DemmandDetail : UIForm
    {
        User me;
        Demmand demmand;

        public DemmandDetail(User me, Demmand demmand)
        {
            InitializeComponent();
            //绑定数据
            ID.Text = demmand.DemmandID;
            Status.Text = demmand.DemmandStatus;
            SenderID.Text = demmand.UserID;
            Address.Text = demmand.DemmandAddress;
            DemmandDeadline.Text = demmand.DemmandDeadline;
            DemmandType.Text = demmand.DemmandType;
            Detail.Text = demmand.DemmandContent;

            this.me = me;
            this.demmand = demmand;
            Color userColor = MainForm.MainForm.userColor;
            UIStyles.InitColorful(userColor, Color.White);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Chat_Click(object sender, EventArgs e)
        {
            UserService userService = new UserService();
            ChatForm chatForm = new ChatForm(me, userService.GetUserByID(demmand.UserID)[0]);
            chatForm.Show();
        }

        private void GetMap_Click(object sender, EventArgs e)
        {
            // 相对于应用程序启动路径的相对路径
            string relativePath = @"..\..\..\Map\map.html";
            string htmlFilePath = " ";

            try
            {
                // 获取应用程序的启动路径
                string appStartupPath = AppDomain.CurrentDomain.BaseDirectory;

                // 合并启动路径和相对路径
                htmlFilePath = Path.GetFullPath(Path.Combine(appStartupPath, relativePath));

                //打开地图
                ProcessStartInfo processStartInfo = new ProcessStartInfo(htmlFilePath);
                Process process = new Process();
                process.StartInfo = processStartInfo;
                process.StartInfo.UseShellExecute = true;
                process.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error opening HTML file: " + ex.Message);
            }
        }

        private void Status_Click(object sender, EventArgs e)
        {

        }
    }
}
